package com.mlog.njyjy.ndop.monitor.collector.service.impl;

import com.mlog.njyjy.ndop.monitor.collector.dao.CollectWayRepository;
import com.mlog.njyjy.ndop.monitor.collector.service.CollectWayService;
import com.mlog.njyjy.ndop.monitor.common.domain.CollectWay;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 采集方式service
 *
 * @author zyz
 * @version v1.0, 2020/07/28
 */
@Slf4j
@Service
public class CollectWayServiceImpl implements CollectWayService {

    @Autowired
    private CollectWayRepository repository;

    @Override
    public List<CollectWay> findAll() {
        return repository.findAll();
    }

    @Override
    public CollectWay findOne(int id) {
        return repository.findOne(id);
    }

    @Override
    public boolean save(CollectWay collectWay) {
        if (collectWay.getId() == 0) {
            return repository.insert(collectWay);
        }
        return repository.update(collectWay);
    }

    @Override
    public boolean delete(int id) {
        return repository.delete(id);
    }
}
